package edu.hawaii.myisern.action;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import edu.hawaii.myisern.model.MyIsernModel;

/**
 * Implements an ActionBean to handle addition/edits of Researchers.
 * 
 * @author Andrew Wong
 * @author Ben
 *
 */

public class EditResearcherActionBean implements ActionBean {
  private MyIsernModel isernData = MyIsernModel.getInstance();

  /** Required by the ActionBean interface. */
  private MyIsernContext context;

  /**
   * Sets the context. Required by the interface. 
   * @param context The ActionBeanContext to set. 
   */
  public void setContext(ActionBeanContext context) {
    this.context = (MyIsernContext) context;
  }

  /**
   * Retrieves name of entry.
   * 
   * @return Name of entry.
   */
  public String getCurrentEntry() {
    return currentEntry;
  }

  /**
   * Returns the context. Required by the interface. 
   * @return the ActionBeanContext.
   */
  public MyIsernContext getContext() {
    return context;
  }

  private String currentEntry;
  
  /**
   * Edits the current entry being edited.
   * 
   * @return Name of entry currently being edited.
   */
  public Resolution setEditEntry() {
    currentEntry = this.context.getCurrentRecord();
    
    return new ForwardResolution("/editResearcher.jsp");
  }
}
